<template>
  <el-collapse v-model="activeName" accordion class="coupon-search__collapse">
    <el-collapse-item name="1">
      <template slot="title">
        <div class="coupon-search__collapse__title">
          <span>优惠券检索</span>
          <span>（点击收起）</span>
        </div>
      </template>
      <div class="coupon-search__container">
        <el-form ref="form" :model="form" label-width="140px">
          <el-form-item label="优惠券名称：">
            <el-input v-model="form.couponName"></el-input>
          </el-form-item>
          <el-form-item label="优惠券类型：">
            <el-radio-group v-model="form.couponType">
              <el-radio label="0">全部</el-radio>
              <el-radio label="1">代金券</el-radio>
              <el-radio label="2">兑换券</el-radio>
              <el-radio label="3">折扣券</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="可用时间：">
            <el-col :span="11">
              <el-date-picker type="datetime" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></el-date-picker>
            </el-col>
            <el-col class="line" :span="2">至</el-col>
            <el-col :span="11">
              <el-date-picker placeholder="结束时间" type="datetime" v-model="form.date2" style="width: 100%;"></el-date-picker>
            </el-col>
          </el-form-item>
          <el-form-item label="可见时间：">
            <el-col :span="11">
              <el-date-picker placeholder="结束时间" type="datetime" v-model="form.date3" style="width: 100%;"></el-date-picker>
            </el-col>
          </el-form-item>
          <el-form-item label="状态：">
            <el-radio-group v-model="form.status">
              <el-radio label="0">全部</el-radio>
              <el-radio label="1">已发布</el-radio>
              <el-radio label="2">待发布</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">检索</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-collapse-item>
  </el-collapse>
</template>

<script>
export default {
  data() {
    return {
      form: {
        couponName: '',
        date1: '',
        date2: '',
        date3: '',
        couponType: '0',
        status: '0'
      },
      activeName: 'couponSearch',
    };
  },

  methods: {
    onSubmit() {
      this.$emit('searchCoupon', this.form);
    }
  }
};
</script>

<style lang="scss" scoped>
.coupon-search {
  margin-bottom: 10px;
  background-color: #ffffff;

  &__collapse {
    border-top: none;
    &__title {
      font-size: 20px;

      span:nth-of-type(2) {
        font-size: 14px;
      }
    }
  }

  &__container {
    padding: 20px 50px 20px 30px;
  }
}
</style>